package ConveyorBelt.Actors;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.geom.Shape;
import org.newdawn.slick.state.BasicGameState;

import ConveyorBelt.Base.Body;
import ConveyorBelt.Base.Entity;
import ConveyorBelt.Base.Level;
import ConveyorBelt.Level.CurrentLevel;

public class Destination extends Body {
	public Image image;
	public boolean toRemove;
	public Color color;
	public Destination(Role role, Shape shape, Image image, Color color) {
		super(role, shape);
		this.image = image;
		this.color = color;
	}
	
	@Override
	public void render(BasicGameState bgs, Graphics g) {
		image.draw(getX(), getY());
	}

	@Override
	public void update(GameContainer gc, int delta) {

	}
	@Override
	public Role getRole() {
		return Role.DESTINATION;
	}

	public Color getColor() {
		return color;
	}
	
	@Override
	public void addToLevel(Level l) {
		l.add(this);
	}

	@Override
	public void removeFromLevel(Level l) {
		l.remove(this);
	}

	@Override
	public void onCollision(Entity obstacle) {
		if(obstacle.getRole() == Role.DUMMY) {
			Dummy dummy = (Dummy) obstacle;
			if(color.equals(dummy.getColor())) {
				CurrentLevel.destinationCount --;
				toRemove = true;
			}
		}
	}

	@Override
	public boolean isToRemove() {
		return toRemove;
	}
	
}
